﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;

namespace TA.Turbo.Controls
{
	/// <summary>
	/// Collection of client-side ID control references.
	/// </summary>
	public class ClientIdCollection : ControlCollection<BaseClientId>
	{
		/// <summary>
		/// Ctor.
		/// </summary>
		/// <param name="owner"></param>
		public ClientIdCollection(Control owner)
			: base(owner)
		{
		}
		/// <summary>
		/// Called when a control is added.
		/// </summary>
		/// <param name="item"></param>
		protected override void OnItemAdded(BaseClientId item)
		{
			base.OnItemAdded(item);

			if (TPage.Current != null)
				TPage.Current.AllClientIds.Add(item);
		}
		/// <summary>
		/// Called when a control is removed.
		/// </summary>
		protected override void OnItemRemoved(BaseClientId item)
		{
			base.OnItemRemoved(item);

			if (TPage.Current != null)
				TPage.Current.AllClientIds.Remove(item);
		}
	}
}
